import path from 'node:path'
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
import { loadEnv } from 'vite'

const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
const {
  VITE_APP_TITLE,
} = env

export default defineUniPages({
  pages: [
    {
      path: 'pages/login/index',
      style: {
        navigationBarTitleText: '登录',
        navigationStyle: 'custom',
      },
      ignoreAuth: true,
    },
    {
      path: 'pages/index/index',
      style: {
        navigationStyle: 'custom',
        navigationBarTitleText: '首页',
      },
      layout: 'home',
      ignoreAuth: true,
    },
    {
      path: 'pages/mine/index',
      style: {
        navigationBarTitleText: '我的',
        navigationStyle: 'custom',
      },
      layout: 'home',
      ignoreAuth: true,
    },
    {
      path: 'pages/agreement/user',
      style: {
        navigationBarTitleText: '用户协议',
        navigationStyle: 'custom',
      },
      layout: 'default',
      ignoreAuth: true,
    },
    {
      path: 'pages/agreement/privacy',
      style: {
        navigationBarTitleText: '隐私协议',
        navigationStyle: 'custom',
      },
      layout: 'default',
      ignoreAuth: true,
    },
  ],
  easycom: {
    autoscan: true,
    custom: {
      '^sar-(.*)': 'sard-uniapp/components/$1/$1.vue',
    },
  },
  globalStyle: {
    navigationBarTextStyle: 'black',
    navigationBarTitleText: VITE_APP_TITLE,
    navigationBarBackgroundColor: '#F8F8F8',
    backgroundColor: '#F8F8F8',
  },
  tabBar: {
    custom: true,
    color: '#999999',
    selectedColor: '#018d71',
    backgroundColor: '#F8F8F8',
    borderStyle: 'black',
    height: '50px',
    fontSize: '10px',
    iconWidth: '24px',
    spacing: '3px',
    list: [
      {
        pagePath: 'pages/index/index',
        text: '首页',
        iconType: 'ui',
        icon: 'list',
      },
      {
        pagePath: 'pages/mine/index',
        text: '我的',
        iconType: 'ui',
        icon: 'person',
      },
    ],
  },
})
